public class demo10 {
    public static void main(String[] args) {
        Thread t = new Thread(() ->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("hello t");
                try{
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    //e.printStackTrace();
                    try{
                        Thread.sleep(2000);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }
                    break;
                }
            }
        });

        t.start();

        try{
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        t.interrupt();
    }
}
